<template>
	<view class="lease_bill_stages">
		<view class="container stages-title u-m-t-20">
			<view class="">
				<text>待缴费用(元)</text>
				<view v-if="orderDetail.status==2"> <u-icon name="info-circle" color="#E95643"></u-icon>
					<text>已逾期</text>
				</view>
			</view>
			<view class="">
				{{orderDetail.pay_amount}}
			</view>
			<view class="">
				还款日:{{orderDetail.estimated_time}}
			</view>
		</view>
		<view class="container">
			<view class="stages-detail row-between">
				<text>还款租金【{{orderDetail.current_periods}}/{{orderDetail.periods}}期】</text>
				<text>￥{{orderDetail.rent}}</text>
			</view>
			<view class="stages-detail row-between" v-if="Number(orderDetail.late_fee)!=0">
				<text>逾期滞纳金</text>
				<text>￥{{orderDetail.late_fee}}</text>
			</view>
			<view class="stages-detail row-between" v-if="Number(orderDetail.change_amount)!=0">
				<text>限时活动</text>
				<text style="color: #E95643">{{orderDetail.change_amount}}</text>
			</view>
			<view class="stages-prompt" v-if="orderDetail.status==2">
				提示:您的账单已逾期，每日将产生滞纳金，请尽快还款以避免额外费用
			</view>
		</view>
		<view class="card-button row-between">
			<view class="meney-all">
				合计 <text>￥</text><text> {{orderDetail.pay_amount}}</text>
			</view>
			<u-button style="flex: 1;" type="primary" shape="circle" @click="confirmReturn">立即支付</u-button>
		</view>
	</view>
</template>

<script>
	import {
		billRepayment
	} from '@/api/lease.js'
	export default {
		data() {
			return {
				reletId: 0, //账单订单id
				orderDetail: {

				},
			}
		},

		methods: {
			// 初始化数据
			indata() {
				billRepayment({
					id: this.reletId,
					action: 'info'
				}).then(res => {
					if (res.code != 1) return;
					this.orderDetail = res.data;

				})
			},

			//立即支付
			confirmReturn() {
				uni.showLoading({
					title: '正在提交...',
					mask: true
				});
				const id = this.orderDetail.id;
				billRepayment({
					action: 'submit',
					id: id
				}).then(res => {
					if (res.code == 1) {
						const data = res.data;
						this.$toast({
							title: res.msg,
							icon: 'success'
						});
						uni.hideLoading();
						//跳转支付页面
						uni.redirectTo({
							url: `/pages/payment/payment?from=${data.from}&order_id=${data.order_id}`
						})
					}
				}).catch(() => {
					uni.hideLoading();
				})

			},


		},

		onLoad(options) {
			const id = options.id
			this.reletId = id;
		},

		onShow() {
			this.indata()
		}
	}
</script>

<style lang="scss" scoped>
	.lease_bill_stages {
		padding: 0 24rpx 0 24rpx;
	}

	.container {
		padding: 22px;
		margin-bottom: 20rpx;
		border-radius: 14rpx;
		background-color: #FFFFFF;

		image {
			border-radius: 12rpx;
		}
	}

	.stages-title {
		text-align: center;

		>view:nth-child(1) {
			color: #00000099;
			font-size: 24rpx;
			font-style: normal;
			font-weight: 500;
			line-height: 24rpx;

			>view {
				// height: 56rpx;
				padding: 16rpx;
				border-radius: 16rpx;
				background: #e956431a;
				color: #E95643;
				display: inline-block;
				margin-left: 20rpx;

				>text {
					margin-left: 10rpx;
				}

			}
		}

		>view:nth-child(2) {
			color: #000000e6;
			font-size: 48rpx;
			font-style: normal;
			font-weight: 900;
			line-height: 48rpx;
			margin-top: 20rpx;
			margin-bottom: 20rpx;
		}

		>view:nth-child(3) {
			color: #00000066;
			font-size: 24rpx;
			font-style: normal;
			font-weight: 500;
			line-height: 24rpx;
		}
	}

	.stages-detail {
		padding: 32rpx 24rpx;
		border-bottom: 1rpx solid #00000011;

		>text:nth-child(1) {
			color: #00000066;

			font-size: 28rpx;
			font-style: normal;
			font-weight: 500;
			line-height: 28rpx;
		}

		>text:nth-child(2) {
			color: #000000e6;

			font-size: 36rpx;
			font-style: normal;
			font-weight: 900;
			line-height: 36rpx;
		}
	}


	.stages-prompt {
		padding: 16rpx 14rpx;

		border-radius: 24rpx;
		background: #c38b611a;
		color: #c38b61;
		font-size: 24rpx;
		font-style: normal;
		font-weight: 500;
		line-height: 32rpx;
		margin-top: 20rpx;
	}

	.card-button {
		position: fixed;
		bottom: 0;
		width: 100%;
		background: #ffffff;
		padding: 30rpx;
		z-index: 1000;
		/* 确保不被其他元素覆盖 */
		left: 0;

	}

	.meney-all {
		color: #000000e6;
		font-size: 28rpx;
		font-style: normal;
		font-weight: 500;
		line-height: 28rpx;
		margin-right: 80rpx;


		>text:nth-child(1) {
			color: #e63333;
			font-size: 24rpx;
			margin-left: 8rpx;
		}

		>text:nth-child(2) {
			color: #e63333;
			font-size: 40rpx;
			font-style: normal;
			font-weight: 900;
			line-height: 40rpx;
		}
	}
</style>